/*
 * To change this license header, choose License Headers in Project Predicate.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package utfpr.cp.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

/**
 *
 * @author Adriano_2
 */
@Entity
public class Predicate implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    private Long id;
    
    @Column(unique = true, nullable = false)
    private String name;
    
    @Enumerated(EnumType.STRING)
    private PredicateType type;
    
    @Column(length = 1000)
    private String description;
    
    private boolean internal;

    public Predicate() {
    }
    
    public Predicate(String name, PredicateType type) {
        this.name = name;
        this.type = type;
        internal = PredicateType.UNKNOWN != type;
    }
    
    public Predicate(String name, PredicateType type, String description) {
        this.name = name;
        this.type = type;
        this.description = description;
        internal = PredicateType.UNKNOWN != type;
    }
    
    public Predicate(String name, PredicateType type, String description, boolean internal) {
        this.name = name;
        this.type = type;
        this.description = description;
        this.internal = internal;
    }
    
    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the type
     */
    public PredicateType getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(PredicateType type) {
        this.type = type;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the internal
     */
    public boolean isInternal() {
        return internal;
    }

    /**
     * @param internal the internal to set
     */
    public void setInternal(boolean internal) {
        this.internal = internal;
    }
    
    public boolean exist() {
        return id != null;
    }
    
}
